-
Notifications
You must be signed in to change notification settings - Fork 3.3k
add bocha web search tool #3142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@weijintaocode is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Greptile OverviewGreptile SummaryThis PR integrates the BoCha AI Search API as a new search tool in Sim, following established patterns from similar integrations like DuckDuckGo and Exa. Key Changes:
Issues Found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant SimUI as Sim UI (Block)
participant Tool as BoCha Tool
participant API as BoCha API
User->>SimUI: Configure search parameters
Note over SimUI: query, freshness, summary,<br/>count, include, exclude, apiKey
User->>SimUI: Execute search
SimUI->>Tool: Call bocha_search tool
Note over Tool: Validate required params<br/>(query, apiKey)
Tool->>API: POST /v1/web-search
Note over API: Authorization: Bearer {apiKey}<br/>Body: search parameters
alt Successful Response
API-->>Tool: 200 OK with search results
Note over Tool: Extract data.data.queryContext<br/>and data.data.webPages.value
Tool-->>SimUI: Return formatted results
SimUI-->>User: Display search results
else Error Response
API-->>Tool: Error response
Tool-->>SimUI: Error (unhandled)
SimUI-->>User: Display error
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 5 comments
| import { DropboxBlock } from '@/blocks/blocks/dropbox' | ||
| import { DSPyBlock } from '@/blocks/blocks/dspy' | ||
| import { DuckDuckGoBlock } from '@/blocks/blocks/duckduckgo' | ||
| import {BoChaBlock} from '@/blocks/blocks/bocha.ts' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary .ts extension in import
| import {BoChaBlock} from '@/blocks/blocks/bocha.ts' | |
| import {BoChaBlock} from '@/blocks/blocks/bocha' |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/blocks/registry.ts
Line: 26:26
Comment:
unnecessary `.ts` extension in import
```suggestion
import {BoChaBlock} from '@/blocks/blocks/bocha'
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| } from '@/tools/dropbox' | ||
| import { chainOfThoughtTool, predictTool, reactTool } from '@/tools/dspy' | ||
| import { duckduckgoSearchTool } from '@/tools/duckduckgo' | ||
| import {bochaSearchTool} from "@/tools/bocha" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inconsistent quote style (use single quotes)
| import {bochaSearchTool} from "@/tools/bocha" | |
| import {bochaSearchTool} from '@/tools/bocha' |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/registry.ts
Line: 210:210
Comment:
inconsistent quote style (use single quotes)
```suggestion
import {bochaSearchTool} from '@/tools/bocha'
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| transformResponse: async (response: Response) => { | ||
| const data = await response.json() | ||
|
|
||
| return { | ||
| success: true, | ||
| output: { | ||
| query: data.data.queryContext.originalQuery, | ||
| results: data.data.webPages.value.map((result: any) => ({ | ||
| title: result.name, | ||
| url: result.url, | ||
| snippet: result.snippet, | ||
| })), | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no error handling for missing or malformed API response structure - will throw if data.data.queryContext or data.data.webPages.value are undefined
| transformResponse: async (response: Response) => { | |
| const data = await response.json() | |
| return { | |
| success: true, | |
| output: { | |
| query: data.data.queryContext.originalQuery, | |
| results: data.data.webPages.value.map((result: any) => ({ | |
| title: result.name, | |
| url: result.url, | |
| snippet: result.snippet, | |
| })), | |
| }, | |
| } | |
| transformResponse: async (response: Response) => { | |
| const data = await response.json() | |
| if (!data?.data?.queryContext?.originalQuery || !data?.data?.webPages?.value) { | |
| throw new Error('Invalid API response structure') | |
| } | |
| return { | |
| success: true, | |
| output: { | |
| query: data.data.queryContext.originalQuery, | |
| results: data.data.webPages.value.map((result: any) => ({ | |
| title: result.name, | |
| url: result.url, | |
| snippet: result.snippet, | |
| })), | |
| }, | |
| } | |
| }, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/bocha/search.ts
Line: 81:94
Comment:
no error handling for missing or malformed API response structure - will throw if `data.data.queryContext` or `data.data.webPages.value` are undefined
```suggestion
transformResponse: async (response: Response) => {
const data = await response.json()
if (!data?.data?.queryContext?.originalQuery || !data?.data?.webPages?.value) {
throw new Error('Invalid API response structure')
}
return {
success: true,
output: {
query: data.data.queryContext.originalQuery,
results: data.data.webPages.value.map((result: any) => ({
title: result.name,
url: result.url,
snippet: result.snippet,
})),
},
}
},
```
How can I resolve this? If you propose a fix, please make it concise.| export interface BoChaSearchParams { | ||
| query: string | ||
| freshness: string | ||
| summary: boolean | ||
| count: number | ||
| include: string | ||
| exclude: string | ||
| apiKey: string | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional fields should use optional property syntax (?) to match how they're used in search.ts:72-76
| export interface BoChaSearchParams { | |
| query: string | |
| freshness: string | |
| summary: boolean | |
| count: number | |
| include: string | |
| exclude: string | |
| apiKey: string | |
| } | |
| export interface BoChaSearchParams { | |
| query: string | |
| freshness?: string | |
| summary?: boolean | |
| count?: number | |
| include?: string | |
| exclude?: string | |
| apiKey: string | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/bocha/types.ts
Line: 27:35
Comment:
optional fields should use optional property syntax (`?`) to match how they're used in `search.ts:72-76`
```suggestion
export interface BoChaSearchParams {
query: string
freshness?: string
summary?: boolean
count?: number
include?: string
exclude?: string
apiKey: string
}
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| title: 'Freshness', | ||
| type: 'long-input', | ||
| placeholder: 'noLimit', | ||
| description: 'Search for web pages within a specified time range(noLimit/oneDay/oneWeek/oneMonth/oneYear/YYYY-MM-DD/YYYY-MM-DD/YYYY-MM-DD..YYYY-MM-DD)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in description - duplicate YYYY-MM-DD in date format examples
| description: 'Search for web pages within a specified time range(noLimit/oneDay/oneWeek/oneMonth/oneYear/YYYY-MM-DD/YYYY-MM-DD/YYYY-MM-DD..YYYY-MM-DD)', | |
| description: 'Search for web pages within a specified time range(noLimit/oneDay/oneWeek/oneMonth/oneYear/YYYY-MM-DD/YYYY-MM-DD..YYYY-MM-DD)', |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/blocks/blocks/bocha.ts
Line: 28:28
Comment:
typo in description - duplicate `YYYY-MM-DD` in date format examples
```suggestion
description: 'Search for web pages within a specified time range(noLimit/oneDay/oneWeek/oneMonth/oneYear/YYYY-MM-DD/YYYY-MM-DD..YYYY-MM-DD)',
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
Add Bocha Search Tool: integrates the Bocha AI Search API to provide web search capabilities
Type of Change
Testing
Tested Manually
Checklist
Demo
Input Configuration

Bocha Configuration

Agent Configuration and Execution Results

Bocha Output
